using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WPGame.Objects;
using WPGame.ResourceManager;
using WPGame.StateManager;

namespace WPGame.States
{
    class PlayState : GState
    {
        private Button m_BackButton;

        private Objects.Obstacle.FourDir m_lotusleaf; //draft

        public PlayState(eGStateGame id)
            : base(id)
        { 
            
        }

        public override void InitStateGame(Microsoft.Xna.Framework.Content.ContentManager Content)
        {
            m_BackButton = new Button(new Vector2(GGlobalSetting.ScreenWidth / 2 - GSpriteFactory.getInstance().getSprite(eGSprite.PLAY_BUTTON).Bound.Width / 2,
                                                  GGlobalSetting.ScreenHeight / 2 - GSpriteFactory.getInstance().getSprite(eGSprite.PLAY_BUTTON).Bound.Height / 2),
                                      GSpriteFactory.getInstance().getSprite(eGSprite.PLAY_BUTTON)
                                      );
            m_BackButton.actionFunc = new Button.Action(goMenuState);

            m_lotusleaf = new Objects.Obstacle.FourDir(new Vector2(50, 50));

            base.InitStateGame(Content);
        }

        public override void UpdateState(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.UpdateState(gameTime);
        }

        public override void HandleInput(Microsoft.Xna.Framework.GameTime gameTime, GInputState Input)
        {
            m_BackButton.HandleInput(Input);
            base.HandleInput(gameTime, Input);
        }

        public override void Render(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            m_BackButton.Render(spriteBatch);
            //m_lotusleaf.Draw(spriteBatch);
            spriteBatch.DrawString(GSpriteFactory.getInstance().getFont(eGFont.ARIAL_FONT), "IN PLAY STATE!", new Vector2(GGlobalSetting.ScreenWidth / 2, 100), Color.White);
            
            base.Render(spriteBatch);
        }

        private void goMenuState()
        {
            GStateManager.getInstance().ExitState();
            GStateManager.getInstance().AddState(new MenuState(eGStateGame.MENU));
        }
    }
}
